// TOWN SCRIPT
//    Town 3: Lizard Tunnels

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

int i,j,k,lvl,choice;

body;

beginstate INIT_STATE;
// This state called whenever this town is entered.
	if (get_flag(11,3) == 0) {
		reset_dialog_preset_options(0);
		add_dialog_str(0,"There's steam coming out of this cave, and it reeks of death. It might be a good idea to exercise a bit of caution while exploring these caverns.",0);
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(11,3,1);
	}	

//Names
	set_name(6,"Captain Baker");
	set_name(7,"Jeff");

	if ((get_flag(200,3) == 11) && (get_flag(101,3) == 1)) {
		erase_char(6);
		erase_char(7);
	}

//Groups
	add_range_to_group(8,18,1);

	set_crime_tolerance(5);

break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;

	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(6,"*groan*");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(7,"Please, help us.");

break;

beginstate 10;
	if (get_flag(0,3) == 0) {
		reset_dialog_preset_options(0);
		add_dialog_str(0,"You step from the entrance into the cave. There are human bodies on the ground. They look as though they suffered violent deaths. The burn marks give a clear indication of what killed them.",0);
		add_dialog_str(1,"It's awfully quiet in here, though.",0);
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(0,3,1);
	}
break;

beginstate 11;
	if (get_flag(1,3) == 0) {
		reset_dialog();
		add_dialog_str(0,"An instant too late, you realize why it's so quiet. The lizards were planning to ambush any who entered the cave. Huge lizards begin crawling out of hiding places to attack you.",0);
		add_dialog_choice(0,"Oops.");
		choice = run_dialog(0);
		if (choice == 1) {
			activate_hidden_group(1);
			set_flag(1,3,1);
		}
	}
break;

beginstate 12;
	if (get_flag(2,3) == 0) {
		reset_dialog_preset_options(0);
		add_dialog_str(0,"You slip through a small opening in the wall here, from where there's a tiny bit of light peeking through. You wouldn't have noticed it if you weren't standing right by it.",0);
		add_dialog_str(1,"However, entering this room so suddenly may have been a slight mistake. There are two things that you notice instantly. The first is that the light is coming from a dying campfire. The second is there are two soldiers here. One standing, one lying down.",0);
		add_dialog_str(2,"Upon your entry, the soldier lying on the mat doesn't move. However, the one standing draws his sword and points it at you shakily. As you step into the light, he notices that you aren't lizards there to kill him, and sheathes his sword, relieved.",0);
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(2,3,1);
	}
break;

beginstate 13;
	if (get_flag(3,3) == 0) {
		reset_dialog_preset_options(0);
		add_dialog_str(0,"Whoa! What happened here? It looks like something big smashed through the wall here. This appears to have been done fairly recently, too.",0);
		add_dialog_str(1,"It's a good bet that the dragon is what caused this. These things don't just happen, and not many living forces have the power to wreak such destruction.",0);
		add_dialog_str(2,"From the look of things, these walls exploded outward, towards where you are. That would mean that the dragon was on the other side of the wall before the demolition. This may be the way into its lair.",0);
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(3,3,1);
	}
break;

beginstate 14;
	if (get_flag(4,3) == 0) {
		reset_dialog_preset_options(0);
		add_dialog_str(0,"Well, it does appear to be a way down, but it's hopefully not the best. The cliffs are too steep to climb back up, and you might not even survive the fall in the first place.",0);
		add_dialog_str(1,"In fact, the edges of the cliffs are kind of steep, and they're covered with loose rocks and dirt. Might want to stay away from this hole altogether.",0);
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(4,3,1);
		block_entry(1);
	}
	else {
		reset_dialog();
		add_dialog_str(0,"Sure enough, as you step out on to the steep, slippery edge, it doesn't take long for you to slip on the rocks and fall headfirst into the pit.",0);
		add_dialog_str(1,"As you approach the ground, you have several seconds to glance at the caverns you're falling through. However, you only manage to catch a glimpse of some spectacular firefalls before concentrating all of your attention on the dragon at the bottom.",0);
		add_dialog_str(2,"Fortunately, the fall kills you, sparing you of whatever horrors the dragon has in store.",0);
		add_dialog_str(3,"Well, it's not like I didn't warn you...",0);
		add_dialog_choice(0,"I hate when you're right.");
		choice = run_dialog(0);
		if (choice == 1)
			kill_char(1000,3,0);
	}
break;

beginstate 15;
	if (get_flag(5,3) == 0) {
		reset_dialog();
		add_dialog_str(0,"The caves are getting hotter in this direction. Maybe you're getting warmer. :P",0);
		add_dialog_choice(0,"Hur hur hur...");
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(5,3,1);
	}
break;

beginstate 16;
	if (get_flag(6,3) == 0) {
		reset_dialog_preset_options(0);
		add_dialog_str(0,"Well, now you know the source of the heat. It remains to be seen if there's anything down here that's worth your time. Or the pain of slogging through molten lava.",0);
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(6,3,1);
	}
break;

beginstate 17;
	if (get_flag(7,3) == 0) {
		reset_dialog();
		add_dialog_str(0,"The lava is emptying the room through a small passage in this corner. While it's big enough for you to fit through fairly easily, it would be a very poor idea to attempt it. What with the lava and all.",0);
		add_dialog_str(1,"Looks like you won't find the way in here.",0);
		add_dialog_choice(0,"Drat.");
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(7,3,1);
	}
break;

beginstate 18;
	if (get_flag (6,3) == 0) {
		reset_dialog_preset_options(0);
		add_dialog_str(0,"Well, now you know where the heat's coming from. A huge firefall is emptying into a pool from a cavern above. It's a breathtaking sight, but it's dreadfully hot in here.",0);
		choice = run_dialog(0);
		if (choice == 1) {
			set_flag(6,3,1);
			set_flag(8,3,1);
		}
	}
break;

beginstate 19;
	if (get_flag (8,3) == 0) {
		reset_dialog_preset_options(0);
		add_dialog_str(0,"Most of the lava seems to have pooled in here. There's a firefall from an upper cavern across this pond from you. It's actually quite pretty, once you can get past the unbearable heat.",0);
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(8,3,1);
	}
break;

beginstate 20;
	if (get_flag (9,3) == 0) {
		reset_dialog();
		add_dialog_str(0,"You'd best be careful here. It'd be quite a fall into the lava. Might sting a little.",0);
		add_dialog_choice(0,"Yeah, yeah...");
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(9,3,1);
	}
break;

beginstate 21;
	if (get_flag (10,3) == 0) {
		reset_dialog_preset_options(0);
		add_dialog_str(0,"The ground stops here. Peering over the edge of the cliff, you can barely even see to the bottom of this drop. There must be a better way to get down.",0);
		choice = run_dialog(0);
		if (choice == 1)
			set_flag(10,3,1);
	}
break;

beginstate 22;
	reset_dialog_preset_options(0);
	add_dialog_str(0,"Some poor soldier met his fate here, by falling off the cliff, no doubt. Oddly, the lizards haven't even touched the body.",0);
	choice = run_dialog(0);
	if (choice == 1);
		end();
break;

beginstate 23;
	move_to_new_town(4,37,7);
break;